package net.cassite.dafstepbystep;

import net.cassite.daf4j.Data;
import net.cassite.daf4j.DataComparable;
import net.cassite.daf4j.DataUtils;
import net.cassite.daf4j.types.XInt;
import net.cassite.daf4j.types.XList;
import net.cassite.daf4j.types.XString;

import javax.persistence.*;
import java.util.List;

/**
 * Created by wkgcass on 15/11/2.
 */
@Entity
public class Role {
        public final DataComparable<Integer> id = new XInt(this);
        public final Data<String> name = new XString(this);

        public final XList<UR> urs = new XList<UR>(this);
        public final XList<RP> rps = new XList<RP>(this);

        @OneToMany(mappedBy = "role")
        public List<RP> getRps() {
                return rps.get();
        }

        public void setRps(List<RP> rps) {
                DataUtils.set(this.rps, rps);
        }

        @OneToMany(mappedBy = "role")
        public List<UR> getUrs() {
                return urs.get();
        }

        public void setUrs(List<UR> urs) {
                DataUtils.set(this.urs, urs);
        }

        @Id
        @GeneratedValue
        public Integer getId() {
                return id.get();
        }

        public void setId(int id) {
                DataUtils.set(this.id, id);
        }

        public String getName() {
                return name.get();
        }

        public void setName(String name) {
                DataUtils.set(this.name, name);
        }
}
